#pragma once

#include "RomSet.h"
#include "types.h"

#define ROM_CPU1			0x0001		//rom belongs in main cpu address space
#define ROM_CPU2			0x0002		//rom belongs in sound cpu address space
#define ROM_CPU3			0x0004		//rom belongs in cpu 3 area
#define ROM_CPU4			0x0008		//rom belongs in cpu 4 area
#define ROM_VROM1			0x0010		//rom belongs in vram area 1
#define ROM_VROM2			0x0020		//rom belongs in vram area 2
#define ROM_VROM3			0x0040		//rom belongs in vram area 3
#define ROM_VROM4			0x0080		//rom belongs in vram area 4
#define ROM_SND1			0x0100		//rom belongs in sound area 1
#define ROM_SND2			0x0200		//rom belongs in sound area 2
#define ROM_PROM			0x0400		//rom belongs in prom
#define ROM_TEMP			0x0800		//rom belongs in temp memory
#define ROM_DECRYPT		0x1000		//tell machine to decrypt when loaded
#define ROM_NOTHING		0x2000		//there is no information
#define ROM_BADDUMP		0x4000		//bad dump only exists
#define ROM_NODUMP		0x8000		//no dump exists

class CRom
{
friend class CRomSet;
protected:
public:
	CRomSet *Owner;					//CRomSet that contains this rom
	char FileName[256];				//filename of the rom
	u32 LoadAddr;						//address it is loaded in to
	u32 Size;							//size of rom
	u32 CRC;								//crc32 of rom
	u32 Flags;							//rom flags
	u8 *Data;							//rom data (after loaded)
	char Name[32];						//name of the romset
public:
	CRom();
	CRom(char *fn,u32 l,u32 s,u32 c,u32 f,char *n);
	virtual ~CRom();
	int Load(char *fn);				//load rom into memory from file
	int LoadZIP(char *zipfn);		//load rom into memory from zip
	int LoadData(u8 *d,int len);	//set rom data info
	void Unload();						//unload rom
	u8 *GetData();						//return pointer to rom data
	void SetInfo(char *fn,u32 a,u32 s,u32 c,u32 f,char *n);	//set rom information
	bool IsEmpty();					//is the rom data ready to be loaded
	bool IsLoaded();					//is the rom data loaded
};
